<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>根据圆的半径计算出圆的周长和面积</title>
 
</head>
<body>
<div>
    <p>圆的半径:<input id="r" type="tetx"></p>
    <p>圆的周长:<input id="cir" type="text"></p>
    <p>圆的面积:<input id="circle" type="type"></p>
</div>
<script>
    var r =prompt('请输入圆的半径');
    r =parseFloat(r) && Number(r);   //获取输入的纯数字，其余情况皆转为NaN
    if(!isNaN(r)){  //判断用户的输入是否是数值
    var cir = 2 * Math.PI.toFixed(2) * r;
    var circle = Math.PI.toFixed(2) * r * r;
    document.getElementById('r').value = r;
    document.getElementById('cir').value = cir.toFixed(2);
    document.getElementById('circle').value = circle.toFixed(2);
 
    }else{
    alert ('请输入正确的数字！');
    }
</script>
</body>
</html>